package com.itheima02;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lenovo
 * Date: 2022-02-09
 * Time: 19:34
 */
/*数组遍历：*/
//public class MethodTest01 {
//    public static void main(String[] args) {
//        System.out.print("[");
//        int[] arr= {11, 22, 33, 44, 55};
//        int x;
//        for( x=0;x<arr.length-1;x++){
//            System.out.print(arr[x]);
//            System.out.print(",");
//        }
//        System.out.print(arr[x]);
//        System.out.println("]");
//    }
//}    有点繁琐
public class MethodTest01 {
    public static void main(String[] args) {
        System.out.print("[");
        int[] arr = {11, 22, 33, 44, 55};
        for (int x = 0; x < arr.length; x++) {
            if (x == arr.length - 1) {
                System.out.print(arr[x]);
            } else {
                System.out.print(arr[x]);
                System.out.print(",");
            }

        }
        System.out.println("]");
    }
}
